﻿namespace Pub.Class
{
    using System;
    using System.Collections;
    using System.Runtime.CompilerServices;
    using System.Text;

    public static class HashtableExtensions
    {
        public static string ToUrl(this Hashtable parameters)
        {
            if (parameters.IsNull() || (parameters.Count == 0))
            {
                return string.Empty;
            }
            StringBuilder sb = new StringBuilder();
            foreach (string str in parameters.Keys)
            {
                sb.AppendFormat("{0}={1}&", str.UrlEncode(), parameters[str].ToString().UrlEncode());
            }
            sb.RemoveLastChar("&");
            return sb.ToString();
        }
    }
}

